package com.example.infoserver.repository;

import com.example.infoserver.entity.Testdata;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TestRepository extends JpaRepository<Testdata,String> {

    List<Testdata> findByMsgtypeAndLoginname(String msgtype,String loginname);
    List<Testdata> findByMsgtypeAndLoginname(String msgtype,String loginname,Pageable pageable);
    List<Testdata> findByLoginname(String loginname,Pageable pageable);

    //查询用户
    @Query(value="from Testdata where loginname =?1")
    @Modifying
    @Transactional
    public List<Testdata> findname(String loginname);

    @Query("update Testdata set msgtype=?1 where id=?2")
    @Modifying
    @Transactional
    int updateNameById(String val1,String val2);

    @Query(value="from Testdata where msgtype =?1")
    @Modifying
    @Transactional
    int getLength(String val1,String val2);
}
